/* eslint-disable @typescript-eslint/no-floating-promises */
// @ts-nocheck
import React, { FC, useEffect, useState } from 'react'
import style from '@/style/articles/tab/category.module.scss'
import { useParams } from 'react-router'
import axios from '@/api/request'
import { useDispatch } from 'react-redux'

const Categroy: FC = () => {
  const params = useParams().id
  const dispatch = useDispatch()
  const [data, setData] = useState()
  useEffect(() => {
    // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
    axios.get(`/wipi/api/article/category/${params}`).then((res) => {
      dispatch({
        type: 'GETDATA',
        payload: [...res.data[0]]
      })
      setData([...res.data[0]])
    })
  }, [])

  return (
    <div className={style.category}>
        <p><span>{params}</span> 分类文章</p>
        <p>共搜索到 <span>{data?.length}</span> 篇</p>
    </div>
  )
}

export default Categroy
